<!--{include header}-->
<script>
	//弹出添加窗口
	function addone()
	{
		var tot = new Date().getTime();
		var url = 'manage.php?c=sysmenu&a=add&t='+tot;
		floatPage(url, '添加菜单', 480, 390, 'location.href=location.href');
		return false;
	}
	
	//弹出编辑窗口
	function editone(id)
	{
		var tot = new Date().getTime();
		var url = 'manage.php?c=sysmenu&a=edit&id='+id+'&t='+tot;
		floatPage(url, '修改菜单', 480, 390, 'location.href=location.href');
		return false;
	}
	
	//弹出删除询问
	function delones(id)
	{
		if(confirm('你确定要删除该菜单项吗？')){
			return ajaxdelone(id);
		}
		return false;
	}
	
	//弹出删除询问
	function delone(id)
	{
		verify('你确定要删除该菜单项吗？', 'ajaxdelone('+id+')');
		return false;
	}
	
	//AJAX删除
	function ajaxdelone(id)
	{
		$.ajax({
			url: 'manage.php?c=sysmenu&a=del&t='+new Date().getTime(),
			data: 'id='+id,
			type: 'post',
			dataType: 'html',
			success: function(res){	
				//alert(res);	
				if(res ==1){
					right('操作已成功！', 'location.href=location.href');
					//TINY.box.hide();
					//messageSuccess('操作已成功！');
					//location.href=location.href;
				}else if(res == 0){
					wrong('菜单ID不能为空！');
				}else if(res == -10){
					wrong('存在有子菜单，请先删除子菜单！');
				}else{
					wrong('系统异常，请联系管理员！');
				}
				return true;
			},
			error: function(){
				wrong('网络异常，请检查网络连接！');
				return false;
			}
		})
	}
	
	//打开与关闭子菜单
	function closeoropen(id, deep)
	{
		var obj =  $('#m_'+id);
		var pobj = $('#ic_'+id);
		var nowDeep = obj.attr('deep');
		
		if(pobj.attr('src') == 'img/icon/tree_open.gif'){
			pobj.attr('src', 'img/icon/tree_close.gif');
		}else{
			pobj.attr('src', 'img/icon/tree_open.gif');
		} 
		obj.nextAll().each(function(){
			if($(this).attr('deep') <= nowDeep) return false;
			//alert(this.style.display);
			if(this.style.display == 'none'){
				$(this).show();
			}else{
				$(this).hide();
			}
		})
	}
	

</script>
	<div class="rightmenu">
		<ul>
            <!--{include menu_right}-->
			<li class="act"><a href="javascript:;" onclick="addone()">添加菜单</a></li>
		</ul>
	</div>
	<div class="workspace" id="workspace">
	<!--列表START-->
	<table cellspacing="0" cellpadding="0" border="0" class="list_tbl">
		<tr class="list_tit">
            <td width="200" class="first">名称</td>
            <td width="60">控制器</td>
            <td width="60">动作</td>
            <td width="40">目标</td>
            <td width="40">类型</td>
            <td width="40">权重</td>
            <td width="40">默认</td>
            <td width="40">隐藏</td>
			<td>备注</td>
			<td width="70">操作</td>
		</tr>
		<!--{if $res['order']}-->
		<!--{loop $res['order'] $index $one}-->
		<tr class="tr_a" id="m_{$one}" deep="{$res['deep'][$index]}">
            <td  class="show_tips" tips="{$res['menu'][$one]['url']}" style="padding-left:<!--{if $res['deep'][$index] == 1}-->5<!--{else}-->{$res['deep'][$index] * 20}<!--{/if}-->px;text-align:left">
           <!--{if !isset($res['deep'][$index+1]) || $res['deep'][$index+1] <= $res['deep'][$index]}--> 
           <img id="ic_{$one}" src="img/icon/tree_close.gif" align="absmiddle"  alt="没有下级菜单" />
           <!--{else}-->
           <a href="javascript:;" onclick="closeoropen({$one}, {$res['deep'][$index]})"><img id="ic_{$one}" src="img/icon/tree_open.gif" align="absmiddle"  alt="拥有下级菜单" /></a>
           <!--{/if}-->
           &nbsp;<a href="{$res['menu'][$one]['url']}" target="_blank">{$res['menu'][$one]['name']}</a>&nbsp;({$one})
            </td>
            <td>{$res['menu'][$one]['ctrl']}</td>
            <td>{$res['menu'][$one]['act']}</td>
            <td>{$res['menu'][$one]['target']}</td>
            <td class="show_tips" tips="
            	<!--{if $res['menu'][$one]['mtype'] == 'SEE'}-->查看<!--{/if}-->
            	<!--{if $res['menu'][$one]['mtype'] == 'ADD'}-->添加<!--{/if}-->
            	<!--{if $res['menu'][$one]['mtype'] == 'EDIT'}-->编辑<!--{/if}-->
            	<!--{if $res['menu'][$one]['mtype'] == 'DEL'}-->删除<!--{/if}-->
            	<!--{if $res['menu'][$one]['mtype'] == 'ALLIN'}-->公共[须登录]<!--{/if}-->
            	<!--{if $res['menu'][$one]['mtype'] == 'ALLOUT'}-->公共[勿登录]<!--{/if}-->
            	<!--{if $res['menu'][$one]['mtype'] == 'OTHER'}-->其它<!--{/if}-->">
				{$res['menu'][$one]['mtype']}
            </td>
            <td>{$res['menu'][$one]['weight']}</td>
            <td><!--{if $res['menu'][$one]['isindex'] == 1}-->是<!--{else}-->否<!--{/if}--></td>
            <td><!--{if $res['menu'][$one]['ishide'] == 1}-->是<!--{else}-->否<!--{/if}--></td>
			<td class="show_tips" tips="{$res['menu'][$one]['notes']}">{$res['menu'][$one]['notes']}</td>
			<td>
				<a onclick="javascript:editone({$res['menu'][$one]['id']});return false;" href="javascript:;">修改</a> |
				<a onclick="javascript:delone({$res['menu'][$one]['id']});return false;" href="javascript:;">删除</a>
			</td>
		</tr>
		<!--{/loop}-->
		<!--{else}-->
		<tr class="tr_b">
			<td colspan="16" style="color:red">没有记录可以显示！</td>
		</tr>
		<!--{/if}-->
	</table>
	<!--列表END-->
	</div>
<!--{include footer}-->





